import dt from '@dt/dt'
import houseOpt from '@/biz/option/house.js'
import toolMgr from '@/biz/base/tool.js'

let orgs = []

function organization(_this) {
  let opt = {
    key: 'orgId',
    title: '所属组织',
    tree: {
      options: orgs,
    }
  }
  toolMgr.organization(2).then(res => {
    orgs = res
    opt.tree.options = orgs
  })
  return opt
}

function options(_this) {
  return [
    organization(_this),
    houseOpt.create({
      to: (info) => {
        return {
          housesId: info.housesId
        }
      }
    }),
    {
      key: 'state',
      title: '审批状态',
      placeholder: '全部',
      select: {
        options: dt.dictInfo().processAuditStatus
      }
    },
    {
      key: 'submitTime',
      title: '提交时间',
      placeholder: '请选择提交时间',
      date: {
        type: 'daterange'
      },
      data: {
        to: (v) => {
          return {
            submitTimeStartDate: v[0],
            submitTimeEndDate: v[1]
          }
        }
      }
    },
  ]
}

export default {
  options
}